package com.colorsstudio.defence.Levels
{
	import com.colorsstudio.defence.ConstantValues.Constants;
	import com.colorsstudio.defence.flashExportClass.*;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import idv.cjcat.fenofsm.events.StateEvent;
	import idv.cjcat.fenofsm.Transition;
	import com.greensock.*;
	import com.greensock.easing.*;
	
	/**
	 * ...
	 * @author wuzhida
	 */
	public class startScreen extends Level
	{
		public var t_Logo_startScreen:Transition;
		public var t_startScreen_Logo:Transition;
		
		//四个按钮：开始游戏、成就、帮助和设置、故事动画
		public var btnPlayGame:SimpleButton;
		public var btnAchiments:SimpleButton;
		public var btnHelpSetting:SimpleButton;
		public var btnStory:SimpleButton;
		
		//游戏背景
		public var backGround:Sprite;
		
		public function startScreen()
		{
			super();
		}
		
		override public function setState():void
		{
			state = Constants.fsm.createState("startScreen");
			t_Logo_startScreen = Constants.fsm.createTransition(Constants.fsm.getStateByName("levelLogo"), state, "toStartScreen", "t_Logo_startScreen", 0);
			t_startScreen_Logo = Constants.fsm.createTransition(state, Constants.fsm.getStateByName("levelLogo"), "backToLogo", "t_startScreen_Logo", 0);
			super.setState();
		}
		
		override public function levelStart(e:StateEvent):void
		{
			super.levelStart(e);
			//trace("Now the start Screen is enter!");
			Constants.main.addChild(this);
			
			thisLevelGosHere();
		
		}
		
		public function thisLevelGosHere():void
		{
			//处理背景和四个按钮。添加到不同layer1、2
			backGround = new f_backGround();
			this.layer1.addChild(backGround);
			
			btnPlayGame = new f_btnPlayGame();			
			this.layer2.addChild(btnPlayGame);
			
			btnAchiments = new f_btnAchiments();
			this.layer2.addChild(btnAchiments);
			
			btnHelpSetting = new f_btnHelpSetting();
			this.layer2.addChild(btnHelpSetting);
			
			btnStory = new f_btnStory();
			this.layer2.addChild(btnStory);
			
			//添加按钮事件
			btnPlayGame.addEventListener(MouseEvent.CLICK, clickPlayGame);
			btnAchiments.addEventListener(MouseEvent.CLICK, clickAchiments);
			btnHelpSetting.addEventListener(MouseEvent.CLICK, clickSetting);
			btnStory.addEventListener(MouseEvent.CLICK, clickStory);		
		}
		
		private function clickStory(e:MouseEvent):void 
		{
			
		}
		
		private function clickSetting(e:MouseEvent):void 
		{
			Constants.fsm.input("toSettingScene");
		}
		
		private function clickAchiments(e:MouseEvent):void 
		{
			Constants.fsm.input("toAchievementsScene");
		}
		
		private function clickPlayGame(e:MouseEvent):void 
		{
			Constants.fsm.input("toGameScene1");
		}
		
		override public function levelEnd(e:StateEvent):void
		{
			super.levelEnd(e);
			Constants.main.removeChild(this);
		}
	
	}

}